package com.zyx.flinkdemo.stream.watermark;

import org.apache.flink.api.common.eventtime.BoundedOutOfOrdernessWatermarks;
import org.apache.flink.api.common.eventtime.WatermarkStrategy;

import java.time.Duration;

/**
 * @author Yaxi.Zhang
 * @since 2021/5/27 17:54
 * desc:
 */
public interface MyWatermarkStrategy<T> extends WatermarkStrategy<T> {
    /**
     * 返回自定义的Watermark生成策略
     * @param maxOutOfOrderness 超时时间
     * @param <T> 泛型
     * @return 自定义Watermark生成策略
     */
    static <T> WatermarkStrategy<T> forMyWatermarkGenerator(Duration maxOutOfOrderness) {
        return (ctx) -> new MyWatermarkGenerator<>(maxOutOfOrderness);
    }
}
